package com.arithmeticEveryDay.blueBridge;

import java.util.HashMap;
import java.util.Scanner;

/*

10 7
1 3 4 2 2 5 6 3 4 1


 */

public class Main18483 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int k = scan.nextInt();
        HashMap<Integer,Integer> map = new HashMap<Integer, Integer>();
        for (int i = 1; i <= n; i++) {
            int value = scan.nextInt();
            int lessTime = i <= n+1-i ? i : n+1-i;
            if (map.get(value) == null || map.get(value) > lessTime) {
                map.put(value, lessTime);
            }
        }
        int minTime = Integer.MAX_VALUE;
        for (Integer value : map.keySet()) {
            System.out.println(value + ", " + map.get(value));
            if (map.containsKey(k - value) && 2 * value != k) {
                minTime = Math.min(minTime, Math.max(map.get(value), map.get(k-value)));
            }
        }
        System.out.println(minTime == Integer.MAX_VALUE ? -1 : minTime);
    }

}
